package org.jeecg.modules.erp.base.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.util.BeanPlusUtil;
import org.jeecg.modules.erp.base.entity.ErpLocation;
import org.jeecg.modules.erp.base.entity.ErpWarehouse;
import org.jeecg.modules.erp.base.mapper.ErpLocationMapper;
import org.jeecg.modules.erp.base.mapper.ErpWarehouseMapper;
import org.jeecg.modules.erp.base.service.IErpLocationService;
import org.jeecg.modules.erp.base.vo.ErpLocationVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description: 库位表
 * @Author: jeecg-boot
 * @Date:   2024-05-18
 * @Version: V1.0
 */
@Service
public class ErpLocationServiceImpl extends ServiceImpl<ErpLocationMapper, ErpLocation> implements IErpLocationService {

    @Autowired
    private ErpWarehouseMapper erpWarehouseMapper;

    @Override
    public IPage<ErpLocationVo> pagelist(Page page, QueryWrapper queryWrapper) {
        return this.baseMapper.pagelist(page,queryWrapper);
    }

    @Override
    public ErpLocationVo info(String id) {
        ErpLocation location = this.getById(id);
        ErpLocationVo erpLocationVo = BeanPlusUtil.toBean(location, ErpLocationVo.class);
        ErpWarehouse erpWarehouse = erpWarehouseMapper.selectById(location.getWareHouseId());
        erpLocationVo.setWarehouseCode(erpWarehouse.getCode());
        erpLocationVo.setWarehouseName(erpWarehouse.getName());
        return erpLocationVo;
    }
}
